Skip to content

Conversation

@TonisPiip
Copy link

Had a nasty issue where I had a large QS be a @class_property, and this code caused it to eval the QS, there's no need to eval it, just pass it directly do isinstance, if we really want a check, a is not None would be better.

But would be even better if this didn't loop over all properities, rather it used

cls._meta.related_objects

@TonisPiip
Copy link
Author

cls._meta._get_fields(reverse=True, forward=False) would be a better option,

I've swtiched to using class_method to avoid this issue, but this was a nasty surprise. :( a warning about using class_property in the docs would be good.

attr = getattr(cls, name, None)

if attr and isinstance(attr, DJANGO_RELATED_FIELD_DESCRIPTOR_CLASSES):
if isinstance(attr, DJANGO_RELATED_FIELD_DESCRIPTOR_CLASSES):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this avoid property evaluation? I'm not sure about it.

Could you make a test to prove it? If not I could help with that.

(sorry about answering so late)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants